﻿/*
 * Copyright (C) 2013 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using UnityEngine;
using System.Collections;

public class CitySpawner : MonoBehaviour {
    public GameObject BuildingPrefab;
    public int Size = 50;
    public float Scale = 30.0f;
    public float MinHeight = 5.0f;
    public float MaxHeight = 30.0f;
    public float HoleProbability = 0.0f;

    // Use this for initialization
    void Start () {
        int i, j;
        for (i = 0; i < Size; i++) {
            for (j = 0; j < Size; j++) {
                if (Random.value < HoleProbability) continue;
                float x = i * Scale - Scale * Size * 0.5f;
                float z = j * Scale - Scale * Size * 0.5f;
                float h = Random.Range (MinHeight, MaxHeight);
                GameObject b = (GameObject)GameObject.Instantiate(BuildingPrefab,
                    new Vector3(x, h * 0.5f, z),
                    Quaternion.identity);
                b.transform.localScale = new Vector3(Scale, h, Scale);
            }
        }
    }

    // Update is called once per frame
    void Update () {

    }
}
